<%-- 
    Document   : odobruvanje
    Created on : 21.6.2011, 21:16:
    Author     : Ruzin
--%>

<%@page import="com.zproekt.servis.OrdinacijaCRUD"%>
<%@page import="com.zproekt.entity.PrivremenTermin"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<link rel="stylesheet" type="text/css" href="style.css" />

<f:view>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
            <title>Одобрување на термини</title>
        </head>
        <body>
            <div class="head">
                <div class="text">
                    Добродојдовте на страната на стоматолошката ординација

                </div>
                <div class="logo"></div>
            </div>  
            <%
                if (request.getSession().getValue("permisija") == null) {
                    response.sendRedirect("index.jsp?error=true");
                }
                String permisija = request.getSession().getValue("permisija").toString();
                if (permisija.equals("user") || permisija.isEmpty()) {
                    response.sendRedirect("user.jsp?error=true");
                }
                // out.println("<h2>"+permisija+"</h2>");
%>
            <%if (request.getParameter("success") != null) {
                    if (request.getParameter("success").equals("vnesenTermin")) {
                        out.println("<h1>Терминот е додаден!</h1>");
                    }
                    if (request.getParameter("success").equals("izbrisanPacient")) {
                        out.println("<h1>Терминот не е одобрен!</h1>");
                    }
                }
                if (request.getParameter("error") != null) {
                    if (request.getParameter("error").equals("pominato")) {
                        out.println("<h1>Датумот кој го избравте е поминат!</h1>");
                    }
                    if (request.getParameter("error").equals("postoi")) {
                        out.println("<h1>Терминот веќе е зафатен!</h1>");
                    }
                }
            %>
            <% java.util.List<PrivremenTermin> lista = OrdinacijaCRUD.getAllTempTermini();
                pageContext.setAttribute("termini", lista);
            %>
            <h1><h:outputText value="Одобрување на термини"/></h1>
            <table border="1">
                <tr>
                    <td>Датум</td>
                    <td>Време</td>
                    <td>Име и Презиме</td>
                    <td>Одобри</td>
                    <td>Избриши</td>
                </tr>
                <c:forEach var="termin" items="${termini}">
                    <tr>
                        <td>${termin.datum}</td>
                        <td>${termin.vreme}</td>
                        <td>${termin.pacient.getIme()} ${termin.pacient.getPrezime()}</td>
                        <td>
                            <form action="odobriTermin.do">
                                <input type="text" name="datum" value="${termin.datum}" style="display: none"/>
                                <input type="text" name="vreme" value="${termin.vreme}" style="display: none"/>
                                <input type="text" name="id" value="${termin.id}" style="display: none"/>
                                <input type="text" name="idPacient" value="${termin.pacient.getId()}" style="display: none"/>
                                <input type="submit" value="Одобри"/>
                            </form>
                        </td>
                        <td>
                            <form action="izbrisiPrivremenTermin.do">
                                <input type="text" name="id" value="${termin.id}" style="display: none"/>
                                <input type="submit" value="Избриши"/>
                            </form>
                        </td>
                    </tr>
                </c:forEach>
            </table>
            <form action="admin.jsp">
                <input type="submit" value="Откажи!"/>
            </form>
            <div class="footer">
                Copyright Ruzin © 2011
            </div>
        </body>
    </html>
</f:view>
